#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define maxn 200200
using namespace std;
struct node
{
	int val;
	int l;
	int r;
}tree[maxn<<2];
int a[maxn];
int pos[maxn];
int ans[maxn];
void build(int rt,int s,int e)
{
	tree[rt].l=s;
	tree[rt].r=e;
	tree[rt].val=e-s+1;
	if(s==e) return ;
	else 
	{
		int mid = (s+e)>>1;
		int l_node = rt*2;
		int r_node = rt*2+1;
		build(l_node,s,mid);
		build(r_node,mid+1,e);
	}
}
int update(int rt,int pos)
{
	tree[rt].val--;
	int l_node = rt*2;
	int r_node = rt*2+1;
	if(tree[rt].l==tree[rt].r) return tree[rt].l;
	if(tree[l_node].val>=pos) update(l_node,pos);
	else 
	{
		pos = pos-tree[l_node].val;
		update(r_node,pos);
	}
}
int main()
{
	int n;
	while(scanf("%d",&n)!=EOF)
	{
		build(1,1,n);
		for(int i = 1;i<=n;i++)
		{
			scanf("%d %d",&pos[i],&a[i]);
		}
		for(int i = n;i>=1;i--)
		{
			int p = update(1,pos[i]+1);
			ans[p] = a[i];
		}
		for(int i = 1;i<=n;i++)
		{
			if(i==1) printf("%d",ans[i]);
			else printf(" %d",ans[i]);
		}
		printf("\n");
	}
}
